from django.db import models
from django.contrib.contenttypes import generic
from base import DataItem, Type, TimeRelation
from core import Person
from structures import Institution

class State(Institution):
    '''
    A state is an institutionalized form of a country
    '''
    citizens = models.ManyToManyField(Person,
                                      symmetrical=False,
                                      through='Nationality',
                                      related_name='nationalities')

    class Meta:
        app_label = 'openpolitics'

class Nationality(TimeRelation):
    '''
    Nationality is a relation between a person and a state 
    '''
    person = models.ForeignKey(Person)
    state = models.ForeignKey(State)

    class Meta:
        verbose_name_plural = 'Nationalities'
        app_label = 'openpolitics'
